home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP02.ZIP / CHAP02 / PATRON / PAGES.H < prev    next >
C/C++ Source or Header  |  1993-04-22  |  4KB  |  139 lines

  1. /*
  2.  * PAGES.H
  3.  * Original Starter Chapter 2
  4.  *
  5.  * Definitions and function prototypes for the Pages window control.
  6.  *
  7.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Software Design Engineer
  10.  * Microsoft Systems Developer Relations
  11.  *
  12.  * Internet  :  kraigb@microsoft.com
  13.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  14.  */
  15.  
  16.  
  17. #ifndef _PAGES_H_
  18. #define _PAGES_H_
  19.  
  20. //Versioning.
  21. #define VERSIONMAJOR                2
  22. #define VERSIONMINOR                0
  23. #define VERSIONCURRENT              0x00020000
  24.  
  25. //Classname
  26. #define SZCLASSPAGES                "pages"
  27.  
  28. #define HIMETRIC_PER_INCH           2540
  29. #define LOMETRIC_PER_INCH           254
  30. #define LOMETRIC_BORDER             60          //Border around page
  31.  
  32.  
  33. //Window extra bytes and offsets
  34. #define CBPAGESWNDEXTRA             (sizeof(LONG))
  35. #define PAGEWL_STRUCTURE            0
  36.  
  37.  
  38. /*
  39.  * Page class describing an individual page and what things it contains.
  40.  *
  41.  * A DWORD is used to identify this page as the name of the storage
  42.  * is the string form of this ID.  If we added a page every second,
  43.  * it would take 136 years to overrun this counter, so we can
  44.  * get away with saving it persistently.  I hope this software is
  45.  * obsolete by then.
  46.  */
  47.  
  48. class __far CPage
  49.     {
  50.     private:
  51.         DWORD       m_dwID;             //Persistent DWORD identifier
  52.  
  53.     public:
  54.         CPage(DWORD);
  55.         ~CPage(void);
  56.  
  57.         DWORD   GetID(void);
  58.     };
  59.  
  60. typedef CPage FAR * LPPAGE;
  61.  
  62.  
  63.  
  64.  
  65. //PAGEWIN.CPP
  66. LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  67. BOOL    __export FAR PASCAL AbortProc(HDC, int);
  68. BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  69.  
  70.  
  71.  
  72. class __far CPages : public CWindow
  73.     {
  74.     friend LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  75.     friend BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  76.  
  77.     private:
  78.         UINT        m_iPageCur;             //Current page we're viewing
  79.         UINT        m_cPages;               //Number of pages
  80.  
  81.         HWND        m_hWndPageList;         //Listbox that manages out page list
  82.         HFONT       m_hFont;                //Page font.
  83.         BOOL        m_fSystemFont;          //Is m_hFont system object?
  84.  
  85.         UINT        m_cx;                   //Current page size in LOMETRIC
  86.         UINT        m_cy;
  87.  
  88.         UINT        m_xMarginLeft;          //Unusable page margins, LOMETRIC
  89.         UINT        m_xMarginRight;
  90.         UINT        m_yMarginTop;
  91.         UINT        m_yMarginBottom;
  92.  
  93.         UINT        m_xPos;                 //Current viewport scroll position.
  94.         UINT        m_yPos;                 //both in *PIXELS*
  95.  
  96.         DWORD       m_dwIDNext;             //Next ID for a page.
  97.  
  98.         HGLOBAL     m_hDevMode;             //Current DevMode configuration
  99.         char        m_szDriver[CCHDEVICENAME];
  100.         char        m_szDevice[CCHDEVICENAME];
  101.         char        m_szPort[CCHDEVICENAME];
  102.  
  103.     private:
  104.         void      Draw(HDC, BOOL, BOOL);
  105.         void      UpdateScrollRanges(void);
  106.         void      RectConvertMappings(LPRECT, HDC, BOOL);
  107.         BOOL      ConfigureForDevice(void);
  108.         BOOL      FPageGet(UINT, LPPAGE FAR *, BOOL);
  109.         BOOL      FPageAdd(UINT, DWORD, BOOL);
  110.  
  111.     public:
  112.         CPages(HINSTANCE);
  113.         ~CPages(void);
  114.  
  115.         BOOL      FInit(HWND, LPRECT, DWORD, UINT, LPVOID);
  116.  
  117.         void      New(void);
  118.         BOOL      Print(HDC, LPSTR, DWORD, UINT, UINT, UINT);
  119.  
  120.         void      RectGet(LPRECT);
  121.         void      RectSet(LPRECT, BOOL);
  122.         void      SizeGet(LPRECT);
  123.         void      SizeSet(LPRECT, BOOL);
  124.  
  125.         UINT      PageInsert(UINT);
  126.         UINT      PageDelete(UINT);
  127.         UINT      CurPageGet(void);
  128.         UINT      CurPageSet(UINT);
  129.         UINT      NumPagesGet(void);
  130.  
  131.         BOOL      DevModeSet(HGLOBAL, HGLOBAL);
  132.         HGLOBAL   DevModeGet(void);
  133.     };
  134.  
  135. typedef CPages FAR * LPCPages;
  136.  
  137.  
  138. #endif  //_PAGES_H_
  139.